#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
ll n, x, k;
char s[N];
ll solve() {
  cin >> n >> x >> k;
  rep(i, 1, n) cin >> s[i];
  int pos0 = 0, pos1 = 0;
  int cnt = 0;
  rep(i, 1, n) {
    if (s[i] == 'L')
      cnt--;
    else
      cnt++;
    if (!cnt && !pos0) pos0 = i;
    if (cnt == -x && !pos1) pos1 = i;
  }
  if (!pos1 || k < pos1) return 0;
  k -= pos1;
  if (!pos0) return 1;
  return 1 + k / pos0;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) cout << solve() << endl;
  return 0;
}